<?php

/**
 * Description of CampoBooleano
 *
 * @author User
 */
class CampoBooleano extends CampoBase {
    
    private $valorChecked = '1';

    protected function setPropriedadesPadrao() {
        $this->setTipoInput('checkbox');        
    }

    public function getHtml() {
        $aAtributos = array();
        $aAtributos['name'] = $this->getNome();
        $aAtributos['id']   = $this->getNome();
        $aAtributos['type'] = $this->getTipoInput();
        if ($this->getClasseCss()) {
            $aAtributos['class'] = $this->getClasseCss();
        }        
        if ($this->getValorChecked()) {
            $aAtributos['value'] = $this->getValorChecked();
        }
        if ($this->getValor()) {
            $aAtributos['checked'] = true;
        }
        $sHtml = '<input '.$this->getHtmlAtributos($aAtributos).' '. 
                           $this->getHtmlEventos().' '.
                           $this->getHtmlCssInline().
                           '/>' . PHP_EOL;        
        return $sHtml;
    }
    
    public function getValorChecked() {
        return $this->valorChecked;
    }

    public function setValorChecked($valorChecked) {
        $this->valorChecked = $valorChecked;
    }

    public function getValor() {
        return (int) parent::getValor();
    }

}

?>
